package com.sleepingcat.flutter_boost_dart.flutter_boost_dart

import android.os.Bundle
import android.view.View
import androidx.activity.addCallback
import com.idlefish.flutterboost.containers.FlutterBoostFragment

/**
 * @作者 志浩
 * @时间 2025/2/28 23:05
 * @描述 TODO
 */
class MyFlutterFragment : FlutterBoostFragment() {
    private val TAG = "FlutterFragment"

    companion object {
        fun build(uniqueId:String?,url: String?,urlParams:Map<String,Any>?): MyFlutterFragment {
            return CachedEngineFragmentBuilder(MyFlutterFragment::class.java)
                .destroyEngineWithFragment(false)
                .uniqueId(uniqueId)
                .url(url)
                .urlParams(urlParams)
                .build()
        }
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        requireActivity().onBackPressedDispatcher.addCallback(this) {
            onBackPressed()
        }
    }

    override fun onResume() {
        super.onResume()
        //透明状态栏
//        requireActivity().immersive(darkMode = true)
    }

    fun manualShow() {
//        didFragmentShow()
    }
}